/**
*	首页
**/
app.controller('gIndexCtrl', ['$scope', '$state', '$stateParams', '$http', '$interval', 'utils',
  function($scope, $state, $stateParams, $http, $interval, utils) {
    // 首页页面数据
    $scope.indexData = {
      bannerList: [],
      zxList: [],
      quickWarning: [],
      expoList: []
    }

    // 首页资讯列表
    utils.get('indexNewsList', {}).success(function (rs) {
      $scope.indexData.zxList = rs.data;
    });

    // 获取banner数据
    utils.get('indexBannerList', {}).success(function (rs) {
      $scope.indexData.bannerList = rs.data;
    });

    // 获取会展数据
    utils.get('indexExpoList', {}).success(function (rs) {
      $scope.indexData.expoList = rs.data;
    });

    $scope.qwIndex = 0;
    // 获取最新公告数据
    utils.get('indexQuickWarning', {}).success(function (rs) {
      $scope.indexData.quickWarning = rs.data;
      var _maxLength = rs.data.length;
      $interval(function() {
        if ($scope.qwIndex === _maxLength-1) {
          $scope.qwIndex = 0;
        } else {
          $scope.qwIndex = $scope.qwIndex + 1;
        }
      }, 2500);
    });


  }
]);
